package ru.kipriz.todoly.api.dao.http;

import ru.kipriz.todoly.api.Parser;
import ru.kipriz.todoly.api.dao.UserDao;
import ru.kipriz.todoly.api.entities.User;

import java.io.IOException;

/**
 * <p>Copyright: Copyright (c) 2010</p>
 *
 * @author Andrey Volkov
 *         <br/>Date: 12/13/10
 */
public class UserDaoHttp implements UserDao {
    public User getUser() {
        try {
            String result = WebRequest.get("user.json");
            return Parser.parseJson(User.class, result);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    public User createUser(User newUser) {
        try {
            String result = WebRequest.post("user.json", Parser.toJson(newUser));
            return Parser.parseJson(User.class, result);
        } catch (IOException e) {
            e.printStackTrace();
            return null;
        }
    }

    public User updateUser(User updatedUser) {
        return null;
    }

    public User deleteUser(User user) {
        return null;
    }
}
